-- 2012-05-17 EM
alter PROCEDURE dbo.sp_check_collector
@phone varchar(20),
@id int OUT,
@firstname varchar(50) OUT
AS
BEGIN
        SET NOCOUNT ON;
exec sms_p.dbo.prints 'Chc 029','sp_check_collector:', @Phone,32
select @Id=u.id, @FirstName=u.comment from dbdata.dbo.users u with(nolock)
        join dbdata.dbo.user_categs uc on u.categ_id=uc.id 
        join dbdata.dbo.phones p on p.uid=u.id 
        where uc.code='Collector' and u.dt_locked is null and p.phone=@phone and p.enabled=1
END
/*
USE [dbproc]
GO
DECLARE @return_value int,
                @id int,
                @firstname varchar(50)

EXEC    @return_value = [dbo].[sp_check_collector]
                @phone = N'79219990001', -- eieannaoi?
                @id = @id OUTPUT,
                @firstname = @firstname OUTPUT

SELECT  @id as N'@id',
                @firstname as N'@firstname'

SELECT  'Return Value' = @return_value

GO
*/
GO

grant execute on sp_check_collector to Executer;
